using System;
using System.Web;
using System.Configuration;
using System.Web.Configuration;
using System.Collections.Specialized;

/// <summary>
/// This is just a generic handler that contains a RssUrlParser object.  It simply passes the url query string from 
/// the HttpRequest to the RssUrlParser which then uses the RssDataManager and the RssFeedWriter to return the RSS 
/// to the user.
/// </summary>
public class RssFeedHandler : IHttpHandler
{
    private string _feed;
    private RssUrlParser _parser;

    public RssFeedHandler()
    {
        _parser = new RssUrlParser();
    }

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/xml";
        RssConfiguration settings = (RssConfiguration)context.GetSection("rssConfiguration");
        string feedId = context.Request.QueryString.GetValues(settings.FeedGuidFieldName)[0];
        _feed = _parser.GetFeed(feedId);
        context.Response.Write(_feed);
        return;
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }


}